package com.peanut.baby.mvp.point;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ListView;

import androidx.annotation.Nullable;

import com.peanut.baby.R;
import com.peanut.baby.model.PointRule;
import com.peanut.baby.mvp.BaseMvpActivity;
import com.peanut.devlibrary.widget.TitleLayout;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by anonymouslystudio on 2017/8/4.
 */

public class PointRulesActivity extends BaseMvpActivity implements TitleLayout.OnTitleClickListener{

    @BindView(R.id.title)
    TitleLayout title;
    @BindView(R.id.point_list)
    ListView rulesList;

    public static void start(Context ctx) {
        ctx.startActivity(new Intent(ctx, PointRulesActivity.class));
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_point_list);
        ButterKnife.bind(this);
        initView();
    }

    private void initView(){
        title.setTitle("花生壳来源");
        title.setOnTitleClickedListener(this);
        View header = LayoutInflater.from(this).inflate(R.layout.layout_point_rule_list_header,null);
        rulesList.addHeaderView(header);
        RulesListAdapter adapter = new RulesListAdapter(this,getRules());
        rulesList.setAdapter(adapter);
    }

    @Override
    public void onTitleBackClicked() {
        finish();
    }

    @Override
    public void onTitleRightClicked() {

    }

    @Override
    public void onTitleClicked() {

    }

    private List<PointRule> getRules(){
        List<PointRule> rules = new ArrayList<>();
        rules.add(new PointRule("注册","新用户积分好礼  注册就送","20"));
        rules.add(new PointRule("签到","天天签到  送不停","5-50"));
        rules.add(new PointRule("任务","任务达人做不停 积分将不停","1-20"));
        rules.add(new PointRule("论坛","玩转论坛 积分得得得","1-20"));
        rules.add(new PointRule("每日记录","争做记录达人","1-10"));
        rules.add(new PointRule("上传头像","从这里开始","10"));
        rules.add(new PointRule("分享给好友","从这里开始","10"));
        return rules;
    }
}
